﻿using Microsoft.EntityFrameworkCore;
using Model;
using System;
using System.Collections.Generic;
using System.Text;

namespace Model
{
    public class SqlExpenseR : IExpenseR
    {
        private readonly AppDbContext _appDbContext;
        public SqlExpenseR(AppDbContext appDbContext)
        {
            _appDbContext = appDbContext;
        }

        /// <summary>
        /// 添加申请报销
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public int Add(ExpenseR e)
        {
           
            _appDbContext.ExpenseR.Add(e);
            return _appDbContext.SaveChanges();
        }

        public IEnumerable<ExpenseR> Rs()
        {
            return _appDbContext.ExpenseR.Include(x=>x.Astate);
        }

        public int update(int id,string name)
        {
            var e = _appDbContext.ExpenseR.Find(id);
            e.Aid = 2;
            _appDbContext.ExpenseR.Update(e);
            return _appDbContext.SaveChanges();
        }
    }
}
